<!DOCTYPE html>
<meta charset="utf-8" />
<link rel="stylesheet" href="ace_v1.3/assets/css/ui.jqgrid.css" />

<div class="search_panel">
<form action="mprcs/bankCardBlacklistManage/queryList.do" method="post" onsubmit="return pageSearch(this);">
	<div style="display: block;" class="widget-body ">
		<div class="widget-main">
			<div class="rowt">
				<div class="col-sm-12">
					<div>
						<div class="search_elms">
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">银行卡号:</label>
								<div class="search_input">
									<input id="cardno" type="text" name="cardno"
										placeholder="请输入银行卡号">
								</div>
							</div>
							<div>
								<div class="search_elm" style="width:180px">
									<label class="label_search" for="userName">卡种:</label>
									<div class="search_input" >
									    <select 
											rel="obj.BANKCARDTYPE"
								 			location="local" 
											name="cardType" 
								 			id="cardType" 
								 			data-placeholder="请选择卡种" style="width: 100px;vertical-align:middle;">
										<option value='' >--请选择--</option>
								 		</select>
									</div>
								</div>
							</div>
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">发卡行代码:</label>
								<div class="search_input">
									<input id="issno" type="text" name="issno"
										placeholder="请输入发卡行代码">
								</div>
							</div>
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">发卡行名称:</label>
								<div class="search_input">
									<input id="issnam" type="text" name="issnam"
										placeholder="请输入发卡行名称">
								</div>
							</div>
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">身份证:</label>
								<div class="search_input">
									<input id="idcardno" type="text" name="idcardno"
										placeholder="请输入持卡人身份证">
								</div>
							</div>
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">持卡人名称:</label>
								<div class="search_input">
									<input id="idcardName" type="text" name="idcardName"
										placeholder="请输入持卡人名称">
								</div>
							</div>
							<div class="search_elm" style="margin-left: 0px">
								<label class="label_search">添加来源:</label>
								<div class="search_input">
									<input id="source" type="text" name="source"
										placeholder="请输入添加来源">
								</div>
							</div>
							
							<div class="search_elm" style="margin-left: 0px;margin-right: 15px;width: 280px;">
								<label class="label_search">添加时间:</label>
								<div class="input-group">
									<input type="text" class="form-control date-picker" name="sdate"  placeholder="起始日期"  data-date-format="yyyy-mm-dd" />
									<span class="input-group-addon">
										<i class="fa fa-exchange"></i>
									</span>
									<input type="text" class="form-control date-picker" name="edate"  placeholder="结束日期"  data-date-format="yyyy-mm-dd"/>
							  </div>
							</div>
							
							<div class="search_button">
								<button class="btn btn-small btn_search" type="submit" title="搜索">
									搜索
								</button>
							</div>
					    </div>
					</div>
				</div>
			</div>
		</div>
	</div>
	</form>
</div>
	<div class="row">
		<div class="col-xs-12">
			<table id="grid-table"></table>
			<div id="grid-pager"></div>
			
			<div style="margin-top: 10px">
				<span id="auth_btn">
					<a auth="mprcs/bankCardBlacklistManage/addView.do" class="btn btn-small btn-add" onclick="addBankCard();">新增</a>
					<a auth="mprcs/bankCardBlacklistManage/editeView.do" class="btn btn-small btn-update" onclick="editBankCard();">修改</a>
					<a auth="mprcs/bankCardBlacklistManage/delete.do" class="btn btn-small btn-delete" onclick="deleteBankCard();">删除</a>
				</span> <span id="paging_bar" style="float: right"> </span>
			</div>
			<!-- PAGE CONTENT ENDS -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->

	<!-- page specific plugin scripts -->
	<script type="text/javascript">
		var jqGrid;
		jQuery(function($) {
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";

			$(window).on(
					'resize.jqGrid',
					function() {
						$(grid_selector).jqGrid('setGridWidth',
								$(".page-content").width());
					})
			var parent_column = $(grid_selector).closest('[class*="col-"]');
			$(document).on(
					'settings.ace.jqGrid',
					function(ev, event_name, collapsed) {
						if (event_name === 'sidebar_collapsed'
								|| event_name === 'main_container_fixed') {
							setTimeout(function() {
								$(grid_selector).jqGrid('setGridWidth',
										parent_column.width());
							}, 0);
						}
					})
			jQuery(grid_selector).jqGrid({

				url : "mprcs/bankCardBlacklistManage/queryList.do",
				datatype : "json",
				height : '100%',
				width : '100%',
				colNames : [ 
				              	'银行卡号',
								'卡种 ',
								'发卡行代码',
								'发卡行名称',
								'持卡人身份证',
								'持卡人名称',
								'添加时间',
								'添加来源',
								'描述信息'
				           ],
				colModel : [ 
							     {name : 'cardno',        index : 'cardno',        width : '145px' }, 
							     {name : 'cardType',        index : 'cardType',        width : '60px' ,ditcKey:'BANKCARDTYPE', formatter : gridFormatByDict}, 
							     {name : 'issno',        index : 'issno',        width : '80px' }, 
							     {name : 'issnam',        index : 'issnam',        width : '150px' }, 
							     {name : 'idcardno',        index : 'idcardno',        width : '145px' }, 
							     {name : 'idcardName',        index : 'idcardName',        width : '100px' }, 
							     {name : 'createDate',        index : 'createDate',        width : '150px' , formatter : gridFormatByDate}, 
							     {name : 'source',        index : 'source',        width : '150px' }, 
							     {name : 'createDesc',        index : 'createDesc',        width : '150px' }
				            ],
				shrinkToFit : false, 
				viewrecords : true,
				rowNum : 10,
				rowList : [ 10, 20, 30 ],
				altRows : true,
				multiselect : true,//设置行可多选的 
				multiboxonly : true,//
				loadComplete : function() {
					var table = this;
					setTimeout(function() {
						//加载分页
						initPagingBar(grid_selector);
					}, 0);
				},
				beforeRequest : function() {//请求之前执行
					jqGrid = this;
				},
			});
			$(window).triggerHandler('resize.jqGrid');

			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});
			
			

		});
		//新增
		function addBankCard() {
			openDialog({
				dialogId : 'dlg-bankCardAdd',
				title : '新增银行卡',
				pageUrl : 'mprcs/bankCardBlacklistManage/addView.do',
				width : '50%',
				height:'70%'
			});
		}
		//修改
		function editBankCard(){
            var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
			
			if (rows.length == 0) {
				msg.alert("警告", "当前没有选择数据项！", "error");
				return;
			}
			if (rows.length > 1) {
				msg.alert("警告", "不能同时选择多项数据！", "warn");
				return;
			}
            var cardno = $('#grid-table').jqGrid('getRowData',rows[0]).cardno;
			
			openDialog({
				dialogId : 'dlg-editBankCard',
				title : '修改银行卡',
				pageUrl : 'mprcs/bankCardBlacklistManage/editeView.do',
				dataUrl : 'mprcs/bankCardBlacklistManage/queryBankCardByNo.do',
				width :'600px',
				height:'400px',
				dataParam : {
					cardno : cardno
				},
				dataName : 'obj' //表单数据存储对象名称

			});
		}
		
		//删除
		function deleteBankCard(){
			var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
			if (rows.length == 0) {
				msg.alert("警告", "当前没有选择数据项！", "warn");
				return;
			}
			
			var ids = "";
			for (var i = 0; i < rows.length; i++) {
				　ids += $('#grid-table').jqGrid('getRowData',rows[i]).cardno+",";
			}
			ids = ids.substring(0, ids.lastIndexOf(","));
			msg.confirm({title:'确认',position:'center',msg:'您确定要删除选中的数据吗？',call:function(ok){
				if(ok){
					$.ajax({
						type : "post",
						url : "mprcs/bankCardBlacklistManage/delete.do?cardno=" + ids,
						dataType : 'json',
						success : function(result) {
							if (result.rspcod != 200) {
								msg.alert("错误", result.rspmsg + " 错误代码："
										+ result.rspcod, 'error');
							} else {
								msg.alert("提示", result.rspmsg, 'correct');
								$("#grid-table").trigger("reloadGrid");
							}
						},
						error : function(XMLHttpRequest, textStatus) {
							msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："
									+ textStatus, 'error');
						}
					});

				}
			}});
			
		}
		
	</script>